var form_FieldRevealer = function(options) {
  var defaults = {
    form : '#form',
    switcher: '#password-cloak',
    revealed: '#input-password-clear',
    hidden: '#input-password-password'
  };
  options = $.extend({}, defaults, options);

  var jForm = $(options.form);
  var jSwitcher = $(options.switcher);
  var jRevealed = $(options.revealed);
  var jHidden = $(options.hidden);

  var oForm = ZForms.getFormById(jForm.attr('id'));
  var oRevealed = oForm.getWidgetById(jRevealed.attr('id'));
  var oHidden = oForm.getWidgetById(jHidden.attr('id'));
  
  jRevealed.keyup(function(){
    oHidden.setValue(oHidden.createValue(oRevealed.getValue().get()));
  });
  jHidden.keyup(function(){
    oRevealed.setValue(oRevealed.createValue(oHidden.getValue().get()));
  });
  jSwitcher.click(function(){
    if(jRevealed.is(':visible'))
    {
      jRevealed.hide();
      jHidden.show();
      jSwitcher.addClass('secret');
    }
    else
    {
      jHidden.hide();
      jRevealed.show();
      jSwitcher.removeClass('secret');
    }
  });
};

var cuttedContent = function(){
	var jContainer = $(".cutted-content");
	var jSwitcher = $(".cutted-content__switcher > span");
  console.log(jSwitcher)
	
	jSwitcher.click(function(){
		$(this).parent().next().slideDown("slow");

    $(this).addClass('hidden');
    //jContainer.animate({height: iContainerHeight}, 500, function(){
		//	jSwitcher.hide();
		//});
	});
};

function servicesMap(options)
{
  var defaults = {
    container : $('#services-type .services-block'),
    item : '>ul>li',
    trigger : '.trigger',
    close : '>ins.icon-close',
    additional : '.additional',
    expandedClass : 'expanded',
    fixMargin: true
  }
  
  this.options = $.extend({}, defaults, options ? options : {});
  
  var current = new jQuery;
  
  var sItem = this.options.item;
  var sTrigger = this.options.trigger;
  var sClose = this.options.close;
  var sAdditional = this.options.additional;
  var exClass = this.options.expandedClass;
  var bFix = this.options.fixMargin;
  
  function closeExpander(e){
    current.css({marginBottom: 0}).removeClass(exClass);
    $(document).unbind('click', closeExpander);
  }
  
  this.options.container.each(function()
  {
    var list = $(this);
    var items = list.find(sItem);
    var trigger = items.filter(sTrigger);
    var close = list.find(sClose);

    trigger.find('a, .pseudo').click(function()
    {
      current.removeClass(exClass);
      current = list;
      var offset = trigger.outerHeight();
      list.addClass(exClass);
      
      if(bFix){
        items.filter(sAdditional).each(function(){
          offset -= $(this).outerHeight();
        });
        list.css({marginBottom: offset});
      }
      
      $(document).bind('click', closeExpander);
      
      return false;
    });
    close.click(closeExpander);
  });
}